package com.taxinfo.view;

import java.util.regex.Pattern;
import java.util.regex.Matcher;

public class SpecialCharExtractor {
    public static void main(String[] args) {
        String input = "aAa生产成本/社会保险费-/设定提存计划离职后福利-基本养老保险费";

        SpecialCharExtractor extractor = new SpecialCharExtractor();
        System.out.println(extractor.getSpecialCharsBySplit(input));;
    }

    private String[] getSpecialCharsBySplit(String input){
        // 定义一个正则表达式，匹配非字母数字字符
        String regex = "[^\\p{Alpha}\\p{Digit}\\u4e00-\\u9fa5]";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(input);
        StringBuilder specialChars = new StringBuilder();
        String split = "";
        while (matcher.find()) {
            System.out.println("Special characters: " + matcher.group());
            split = matcher.group();
            break;
        }
        String[] rtnVal  = input.split(split);
        for (int i = 0; i < rtnVal.length; i++) {
            System.out.println(rtnVal[i]);
        }
        return rtnVal;
    }
}